package com.serviceImpl;

import com.dao.SpaceDao;
import com.domain.Space;
import com.server.SpaceService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("spaceService")
public class SpaceServiceImpl implements SpaceService {

    @Resource(name="spaceDao")
    private SpaceDao spaceDao;

    @Override
    public List<Space> selectSpaceAll() { return spaceDao.selectSpaceAll(); }

    @Override
    public List<Space> selectSpaceByUserId(Integer userId) { return spaceDao.selectSpaceByUserId(userId); }

    @Override
    public Space selectSpaceByNameAndUserId(String name, Integer userId) { return spaceDao.selectSpaceByNameAndUserId(name,userId); }

    @Override
    public Space selectSpaceByIdAndUserId(@Param("space_id") Integer space_id, @Param("userId") Integer userId){ return spaceDao.selectSpaceByIdAndUserId(space_id,userId); }

    @Override
    public Space selectSpaceByName(String name) { return spaceDao.selectSpaceByName(name); }

    @Override
    public Space selectSpaceById(Integer id) { return spaceDao.selectSpaceById(id); }

    @Override
    public List<Space> descCreateDate() { return spaceDao.descCreateDate(); }

    @Override
    public Space descCreateDateByUserId(Integer userId) { return spaceDao.descCreateDateByUserId(userId); }

    @Override
    public int insertSpace(Space space) { return spaceDao.insertSpace(space); }

    @Override
    public int deleteById(Integer id) { return spaceDao.deleteById(id); }

    @Override
    public int deleteByUserId(@Param("space_id") Integer space_id, @Param("userId") Integer userId) { return spaceDao.deleteByUserId(userId,space_id); }

    @Override
    public int updateSpaceById(Space space) { return spaceDao.updateSpaceById(space); }

    @Override
    public int selectUserIdBySpaceId(int id) {
        return spaceDao.selectUserIdBySpaceId(id);
    }

    @Override
    public List<Space> findAllSpace(int page, int pageSize) {
        int from=(page-1)*pageSize;
        return spaceDao.findAllSpace(from,pageSize);
    }

    @Override
    public int findSpaceTotal() {
        return spaceDao.findSpaceTotal();
    }

}
